package com.ukao.cashregister.adapter;

import android.content.Context;
import android.widget.TextView;

import com.mcxtzhang.commonadapter.rv.CommonAdapter;
import com.mcxtzhang.commonadapter.rv.ViewHolder;
import com.ukao.cashregister.R;
import com.ukao.cashregister.bean.Coupons;
import com.ukao.cashregister.utils.CheckUtils;
import com.ukao.cashregister.utils.MyDateUtils;

import java.util.List;

/**
 * 优惠券
 */

public class CouponAdapter extends CommonAdapter<Coupons> {




    public CouponAdapter(Context context, List<Coupons> datas) {
        super(context, datas, R.layout.adapter_coupon);
    }


    @Override
    public void convert(ViewHolder viewHolder, Coupons coupons) {
        TextView  name=viewHolder.getView(R.id.name);
        TextView usedTime= viewHolder.getView(R.id.usedTime);
        TextView  timeStart=viewHolder.getView(R.id.timeStart);
        TextView   amount=viewHolder.getView(R.id.amount);
        TextView   fullAmount= viewHolder.getView(R.id.fullAmount);
        TextView   isOverdue= viewHolder.getView(R.id.isOverdue);

        name.setText(CheckUtils.isEmptyString(coupons.getName()));
        timeStart.setText(MyDateUtils.formatDateCustom(coupons.getTimeStart(),"yyyy.MM.dd") + " 至 " + MyDateUtils.formatDateCustom(coupons.getTimeEnd(),"yyyy.MM.dd")+"有效");/*时间*/
        usedTime.setText("使用时间："+MyDateUtils.formatDateCustom(coupons.getUsedTime(),"yyyy/MM/dd HH:mm:ss"));
        amount.setText("面额："+CheckUtils.isEmptyNumber(coupons.getAmount()));/*标题*/
        fullAmount.setText("使用限制："+(coupons.fullAmount == 0 ? "无限制" : "满" + CheckUtils.isEmptyNumber(coupons.getFullAmount()) + "可使用"));

        isOverdue.setText(coupons.getUseStatusText());
//        if (coupons.getIsOverdue()){ /*过期*/
//            isOverdue.setText(coupons.getUseStatusText());
//            isOverdue.setTextColor(mContext.getResources().getColor(R.color.pay_gay));
//        }
//
//        if (coupons.getUseStatus()){/*使用*/
//
//            isOverdue.setTextColor(mContext.getResources().getColor(R.color.green));
//        }

    }


}
